package com.wxc.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

import java.util.Objects;

public enum StateEnum {

    ENABLE(1, "启用"),
    DISABLE(0, "禁用");

    private final String descp;

    @EnumValue
    private int code;
    private String Descp;

    @JsonValue
    public int getCode() {
        return this.code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public void setDescp(String Descp) {
        this.Descp = Descp;
    }

    public String getDescp() {
        return descp;
    }

    @JsonCreator
    public static StateEnum getByCode(int code) {
        for (StateEnum value : StateEnum.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value;
            }
        }
        return null;
    }

    public static String getByDescp(int code) {
        for (StateEnum value : StateEnum.values()) {
            if (Objects.equals(code, value.getCode())) {
                return value.getDescp();
            }
        }
        return null;
    }


    StateEnum(int code, String descp) {
        this.code = code;
        this.descp = descp;
    }


}
